<template>
  <el-dialog
    title="提示"
    :visible.sync="visible"
    width="30%"
    :before-close="close"
  >
    <div class="box">
      <div>
        <el-date-picker
        v-model="value1"
        type="datetimerange"
        value-format="yyyy-MM-dd HH:mm:ss"
        range-separator="至"
        :unlink-panels="true"
        style="width: 80%; margin-right: 15px"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      >
      </el-date-picker>
      <el-button @click="submit">查询</el-button>
      </div>
      <div style="height: 100%;overflow: auto;display: flex;flex-direction: column;align-items: center;">
        <div v-for="item in dataKey" style="margin: 15px 0;width: 50%;">
            <span>{{ item }}</span>:
            <span>{{ data[item] }}</span>
        </div>
      </div>
    </div>

    <span slot="footer" class="dialog-footer">
      <el-button @click="quxiao(false)">关闭</el-button>
    </span>
  </el-dialog>
</template>
<script>
import request from "@/utils/request";
export default {
  props: {
    isUp: {
      type: Boolean,
      default: false,
    },
  },

  data() {
    return {
      visible: null,
      value1: "",
      data: {},
      dataKey:[]
    };
  },
  watch: {
    isUp: {
      handler: function (n, o) {
        this.visible = n;
      },
      immediate: true,
    },
  },
  methods: {
    quxiao(val) {
      this.$emit("clickIsUp", val);
    },
    close() {
      this.$emit("clickIsUp", false);
    },
    submit() {
      console.log(this.value1);
      let obj = {
        startTime: this.value1[0] ? this.value1[0] : '',
        endTime: this.value1[1] ? this.value1[1] : '',
      };

      request({
        url: "/system/bank/entryData",
        method: "post",
        data: obj,
      }).then((res) => {
        console.log(res);
        if (res.code == 200) {
          this.data = res.data;
        this.dataKey=  Object.keys(res.data)
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.el-dialog {
  min-width: 500px;
}
.box {
  height: 500px;
}
</style>
